<!-- 纵向布局 -->
<template>
  <el-container class="layout">
    <el-aside>
      <div :style="{ width: isCollapse ? '65px' : '210px' }" class="aside-box">
        <div class="logo flx-center">
          <!--          <img alt="logo" class="logo-img" src="@/assets/images/logo.svg" />-->
          <span v-show="!isCollapse" class="font-bold text-lg">{{ title }}</span>
        </div>
        <el-scrollbar>
          <el-menu
            :collapse="isCollapse"
            :collapse-transition="false"
            :default-active="activeMenu"
            :router="false"
            :unique-opened="accordion"
          >
            <SubMenu :menu-list="menuList" />
          </el-menu>
        </el-scrollbar>
      </div>
    </el-aside>
    <el-container>
      <el-header>
        <ToolBarLeft />
        <ToolBarRight />
      </el-header>
      <Main />
    </el-container>
  </el-container>
</template>

<script lang="ts" name="layoutVertical" setup>
import { computed, onMounted, ref } from "vue";
import { useRoute } from "vue-router";
import { useAuthStore } from "@/stores/modules/auth";
import { useGlobalStore } from "@/stores/modules/global";
import Main from "@/layouts/components/Main/index.vue";
import ToolBarLeft from "@/layouts/components/Header/ToolBarLeft.vue";
import ToolBarRight from "@/layouts/components/Header/ToolBarRight.vue";
import SubMenu from "@/layouts/components/Menu/SubMenu.vue";
import { requestSysCommonGetConfigs } from "@/api/modules/sysCommon";

import { ResultData } from "@/api/interface";
import { SysKeyWebTitle } from "@/constant/syscnt/sys";

const title = ref(import.meta.env.VITE_GLOB_APP_TITLE);
onMounted(() => {
  requestSysCommonGetConfigs([SysKeyWebTitle]).then((res: ResultData) => {
    if (res.data[SysKeyWebTitle]) {
      title.value = res.data[SysKeyWebTitle];
    }
  });
});
const route = useRoute();
const authStore = useAuthStore();
const globalStore = useGlobalStore();
const accordion = computed(() => globalStore.accordion);
const isCollapse = computed(() => globalStore.isCollapse);
const menuList = computed(() => authStore.showMenuListGet);
const activeMenu = computed(() => (route.meta.activeMenu ? route.meta.activeMenu : route.path) as string);
</script>

<style lang="scss" scoped>
@import "./index.scss";
</style>
